CFLAGS = -Wall -fpic -coverage -lm

rngs.o: rngs.h rngs.c
	gcc -c rngs.c -g  $(CFLAGS)

dominion.o: dominion.h dominion.c rngs.o
	gcc -c dominion.c -g  $(CFLAGS)

playdom: dominion.o playdom.c
	gcc -o playdom playdom.c -g dominion.o rngs.o $(CFLAGS)

testDrawCard: testDrawCard.c dominion.o rngs.o
	gcc -o testDrawCard -g  testDrawCard.c dominion.o rngs.o $(CFLAGS)

badTestDrawCard: badTestDrawCard.c dominion.o rngs.o
	gcc -o badTestDrawCard -g  badTestDrawCard.c dominion.o rngs.o $(CFLAGS)

testBuyCard: testBuyCard.c dominion.o rngs.o
	gcc -o testBuyCard -g  testBuyCard.c dominion.o rngs.o $(CFLAGS)

testAll: dominion.o testSuite.c
	gcc -o testSuite testSuite.c -g  dominion.o rngs.o $(CFLAGS)

interface.o: interface.h interface.c
	gcc -c interface.c -g  $(CFLAGS)

unittest1: unittest1.h unittest1.c dominion.o
	gcc -o unittest1 -g unittest1.c -g dominion.o rngs.o $(CFLAGS)
unittest2: unittest2.h unittest2.c dominion.o
	gcc -o unittest2 unittest2.c -g dominion.o rngs.o $(CFLAGS)
unittest3: unittest3.h unittest3.c dominion.o
	gcc -o unittest3 unittest3.c -g dominion.o rngs.o $(CFLAGS)
unittest4: unittest4.h unittest4.c dominion.o
	gcc -o unittest4 unittest4.c -g dominion.o rngs.o $(CFLAGS)
cardtest1: cardtest1.h cardtest1.c dominion.o
	gcc -o cardtest1 -g cardtest1.c -g dominion.o rngs.o $(CFLAGS)
cardtest2: cardtest2.h cardtest2.c dominion.o
	gcc -o cardTest2 -g cardTest2.c -g dominion.o rngs.o $(CFLAGS)
cardtest3: cardtest3.h cardtest3.c dominion.o
	gcc -o cardtest3 -g cardtest3.c -g dominion.o rngs.o $(CFLAGS)
cardtest4: cardtest4.h cardtest4.c dominion.o
	gcc -o cardtest4 -g cardtest4.c -g dominion.o rngs.o $(CFLAGS)
randomtestadventurer: randomtestadventurer.h randomtestadventurer.c dominion.o
	gcc -o randomtestadventurer randomtestadventurer.c -g dominion.o rngs.o $(CFLAGS)
randomtestcard: randomtestcard.h randomtestcard.c dominion.o
	gcc -o randomtestcard randomtestcard.c -g dominion.o rngs.o $(CFLAGS)

unittestresults.out: unittest1 unittest2 unittest3 unittest4 cardtest1 cardtest2 cardtest3 cardtest4 dominion.o
	./unittest1 >> unittestresults.out
	./unittest2 >> unittestresults.out
	./unittest3 >> unittestresults.out
	./unittest4 >> unittestresults.out
	./cardtest1 >> unittestresults.out
	./cardtest2 >> unittestresults.out
	./cardtest3 >> unittestresults.out
	./cardtest4 >> unittestresults.out
	/usr/bin/gcov dominion.c -f -b  >> unittestresults.out

testdominion : testdominion.h testdominion.c dominion.o rngs.o interface.o testInitializeGame.o testGetWinners.o testScoreFor.o testfunctions.o testUpdateCoins.o
	gcc -o testdominion testdominion.c -g dominion.o rngs.o interface.o testInitializeGame.o testGetWinners.o testfunctions.o testUpdateCoins.o $(CFLAGS)

testfunctions.o: testfunctions.h testfunctions.c dominion.o
	gcc -c testfunctions.c -g $(CFLAGS)
testdominion.out : testdominion
	./testdominion >> testdominion.out
gameResults.out : testdominion
	./testdominion > gameResults.out
randomtestcard.out: randomtestcard
	./randomtestcard >> randomtestcard.out
	/usr/bin/gcov dominion.c -f -b >> randomtestcard.out
testUpdateCoins.o: testUpdateCoins.c testUpdateCoins.h dominion.o
	gcc -c testUpdateCoins.c -g $(CFLAGS)
randomtestadventurer.out: randomtestadventurer
	./randomtestadventurer >> randomtestcard.out
	/usr/bin/gcov dominion.c -f -b >> randomtestadventurer.out

testIsGameOver: testIsGameOver.h testIsGameOver.c dominion.o interface.o
	gcc -o testIsGameOver testIsGameOver.c -g dominion.o rngs.o interface.o $(CFLAGS)

tstShuffle: tstShuffle.h tstShuffle.c dominion.o interface.o
	gcc -o tstShuffle tstShuffle.c -g dominion.o rngs.o interface.o $(CFLAGS)

tstDrawCard: tstDrawCard.h tstDrawCard.c dominion.o interface.o
	gcc -o tstDrawCard tstDrawCard.c -g dominion.o rngs.o interface.o $(CFLAGS)

testScoreFor.o: testScoreFor.h testScoreFor.c dominion.o interface.o
	gcc -c testScoreFor.c -g $(CFLAGS)

testGetWinners.o: testGetWinners.h testGetWinners.c dominion.o interface.o testScoreFor.o
	gcc -c testGetWinners.c -g $(CFLAGS)

testUpdateCoins: testUpdateCoins.h testUpdateCoins.c dominion.o interface.o
	gcc -o testUpdateCoins testUpdateCoins.c -g dominion.o rngs.o interface.o $(CFLAGS)

testInitializeGame.o: testInitializeGame.h testInitializeGame.c dominion.o interface.o
	gcc -c testInitializeGame.c -g $(CFLAGS)
player: player.c interface.o
	gcc -o player player.c -g  dominion.o rngs.o interface.o $(CFLAGS)
testcardEffect: testcardEffect.c dominion.o rngs.o interface.o
	gcc -o testcardEffect testcardEffect.c -g dominion.o rngs.o interface.o $(CFLAGS)
all: playdom player testDrawCard testBuyCard badTestDrawCard

clean:
	rm -f *.o playdom.exe playdom test.exe test testcardEffect testdominion player player.exe testDrawCard testDrawCard.exe testBuyCard testBuyCard.exe badTestDrawCard badTestDrawCard.exe *.gcov *.gcda *.gcno *.so *.out unittest1 unittest2 unittest3 unittest4 cardtest1 cardtest2 cardtest3 cardtest4
